<?php

namespace Admin\Controller;
//use Think\Controller;
use Tools\AdminController;
//use Think\Verify
class ManagerController extends AdminController{
   function login(){
       if(!empty($_POST)){
           $vry = new \Think\Verify();
           if($vry -> check($_POST['captcha'])){
              //用户名和密码校验 
               $manager = new \Model\ManagerModel;
               $info = $manager -> checknamepwd($_POST['admin_user'],$_POST['admin_pwd']);
               if ($info){
                   session('admin_id',$info['mg_id']);
                   session('admin_name',$info['mg_name']);
//                   dump(session('admin_name'));获取session指定信息
                   $this->redirect('Index/index');
               }else
                 echo  '用户名或密码错误';
           }else
               echo '验证码错误';
       }
       //显示系统定义常量
//       dump(get_defined_constants(true));
       $this->display();
   } 
   function logout(){
       session(null);
       $this->redirect('login');
   }
   function verifyImg(){
       //给验证码做配置
       $cfg = array(
           'imageH'    =>  45,
           'imageW'    =>  100,
           'fontSize'  =>  15,
           'length'    =>  4,
           'fontttf'   =>  '4.ttf',
        );
       $very = new \Think\Verify($cfg);
       $very ->entry();
   }
   function showlist(){
       $manager = D('Manager')->select();
      $this->assign('manager_info',$manager);
       $this->display();
   }
}
